package com.example.hy2110szyx.controller;

import com.example.hy2110szyx.entity.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpSession;

@Controller
public class HomeController {

    @GetMapping("/")
    public String home() {
        return "login";
    }

    @GetMapping("/wel")
    public String toWel() {
        return "welcome";
    }

    @GetMapping("/login")
    public String toLogin() {
        return "login";
    }

    @GetMapping("/main")
    public String main(){
        return "main";
    }

    //@GetMapping("/stu/main")
    //public String toStudent() {
    //    return "student";
    //}

    @GetMapping("/flight/main")
    public String toFlight() {
        return "flight";
    }

    @GetMapping("/distribution/main")
    public String toDistribution() {
        return "distribution";
    }

    @GetMapping("/passenger/main")
    public String toPassenger() {
        return "passenger";
    }

    @GetMapping("/reservation/main")
    public String toReservation() {
        return "reservation";
    }

    @GetMapping("/system/main")
    public String toSystem(HttpSession session) {
        UserInfo loginUser = (UserInfo) session.getAttribute("loginUser");
        if (loginUser.getRole() != 2) {
            return "error/403";
        }else {
            return "system";
        }
    }
}
